﻿<Application 
    x:Class="ChinaUnicom.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:src="clr-namespace:ChinaUnicom.Converters"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <!--Application Resources-->
    <Application.Resources>

        <src:DateConverter x:Key="dateConverter"/>
        <src:BooleanVisibilityConverter x:Key="booleanVisibilityConverter"/>
        <src:ThemeConverter x:Key="themeConverter"/>
        <src:TrafficConverter x:Key="trafficConverter"/>

        <SolidColorBrush x:Key="ThemeLogoBrush" Color="#FF9F0802"/>

        <Style x:Key="PulledTextStyle" TargetType="TextBlock">
            <Setter Property="Opacity" Value="0.5"/>
        </Style>

        <Style x:Key="PageTopRectangleStyle" TargetType="Rectangle">
            <Setter Property="Fill" Value="{StaticResource ThemeLogoBrush}"/>
            <Setter Property="Height" Value="5"/>
        </Style>
        <Style x:Key="PageTopBorderStyle" TargetType="Border">
            <Setter Property="Background" Value="{StaticResource ThemeLogoBrush}"/>
            <Setter Property="Margin" Value="20, 0, 0, 0"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
        </Style>
        <Style x:Key="PageTopTextStyle" TargetType="TextBlock" BasedOn="{StaticResource PhoneTextNormalStyle}">
            <Setter Property="Height" Value="30"/>
            <Setter Property="Foreground" Value="White"/>
        </Style>

        <DataTemplate x:Key="BasicTextTemplate">
            <StackPanel Margin="0, 10, 0, 0">
                <TextBlock Text="{Binding Name}" FontSize="30"/>
                <TextBlock Text="{Binding Value}" Foreground="{StaticResource PhoneAccentBrush}"/>
            </StackPanel>
        </DataTemplate>

        <ControlTemplate x:Key="SampleButtonTemplate" TargetType="Button">
            <Grid>
                <ContentPresenter/>
            </Grid>
        </ControlTemplate>

        <Style x:Key="FurtherIconButtonStyle" TargetType="Border">
            <Setter Property="Height" Value="48"/>
            <Setter Property="Width" Value="48"/>
            <Setter Property="CornerRadius" Value="24"/>
            <Setter Property="BorderThickness" Value="3"/>
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
        </Style>

        <Style x:Key="LogoutIconStyle" TargetType="Image">
            <Setter Property="Source" Value="/Themes/Dark/Images/logout.png"/>
            <Setter Property="Height" Value="48"/>
            <Setter Property="Width" Value="48"/>
        </Style>

        <!-- for control buttons ControlTemplate-->
        <ControlTemplate x:Key="FurtherIconButton" TargetType="Button">
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="MouseOver"/>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneForegroundBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="icon"
                Storyboard.TargetProperty="Source">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="/Themes/Light/Images/go.png"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled"/>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="border" 
                        Style="{StaticResource FurtherIconButtonStyle}">
                    <Image x:Name="icon" Source="/Themes/Dark/Images/go.png"/>
                </Border>
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="MoreItemIconButton" TargetType="Button">
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal"/>
                        <VisualState x:Name="MouseOver"/>
                        <VisualState x:Name="Pressed">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="Background">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource PhoneForegroundBrush}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="border"
                Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames
                Storyboard.TargetName="icon"
                Storyboard.TargetProperty="Source">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="/Themes/Light/Images/go.png"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Disabled"/>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="100"/>
                    </Grid.ColumnDefinitions>
                    <ContentPresenter/>
                    <Border x:Name="border" 
                            Style="{StaticResource FurtherIconButtonStyle}"
                            Grid.Column="1"
                            HorizontalAlignment="Center">
                        <Image x:Name="icon" Source="/Themes/Dark/Images/go.png"/>
                    </Border>
                </Grid>
            </Grid>
        </ControlTemplate>
        <!-- for control buttons ControlTemplate-->

    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService 
            Launching="Application_Launching" Closing="Application_Closing" 
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>